import request from "../../../utils/request"
import { getShowImage, showModal, showToast } from "../../../utils"

export default {
	download(id) {
		//获取资料的下载链接
		request({
			url: "information/downloadInformation",
			data: {
				id,
			},
			showLoading: true,
			errorHandle: true,
		}).then(async (data) => {
			const fileUrl = data.fileUrl
			await showModal({
				title: "提示",
				content: "由于微信小程序限制，无法直接下载文件，请复制链接后自行到浏览器进行下载",
				confirmText: "复制链接",
				showCancel: false,
			})
			wx.setClipboardData({
				data: getShowImage(fileUrl),
				success() {
					showToast.success("复制成功")
				},
			})
		})
	},
}